﻿using System;
using System.Web;
using System.Web.UI;
using System.Linq;
using Models;


public partial class TagAdd : AdminBase
{
    public int _Id = 0;
    public string _type = "", guid = "";

    protected void Page_Load(object sender, EventArgs e)
    {

        Response.CacheControl = "no-cache";
        if (!string.IsNullOrEmpty(Request.Params["guid"]))
        {
            guid = HttpContext.Current.Request.QueryString["guid"];
        }

        if (!Page.IsPostBack)
        {

           
                ShowInfo(guid);
            
        }
    }

    private void ShowInfo(string _id)
    {

        Entities mydb = new Entities();
        {
            User _lt = mydb.User.First(p => p.UOpenID == _id);
            txtTel.Text = _lt.UTel;
            txtName.Text = _lt.UTrueName + _lt.UNickName;


            var bb = mydb.U_CZ.Where(x=>x.UGuid== _id).OrderByDescending(x => x.CZID);


            this.rptList.DataSource = bb.ToList();  //这里好像一定要Tolist();不然会有点错误；
            this.rptList.DataBind();

        }
    }


    protected void Button1_Click(object sender, EventArgs e)
    {
        Entities mydb = new Entities();
        {

            U_CZ cz = new U_CZ();
            cz.UGuid = guid;
            cz.CZTime = DateTime.Now;
            cz.CZPayType = "后台充值";
            cz.CZstat = 1;
            cz.Other = Session["adminID"].ToString();
            cz.CZMoney = decimal.Parse(txtCZ.Text.Trim());
            mydb.U_CZ.Add(cz);
            mydb.SaveChanges();
            Response.Write("<script> var Close=1;</script>");
        }
    }
}

